import { defineStore } from 'pinia';

const name = 'TOKEN';

export const useLoginedStore = defineStore('logined', {
  state: () => {
    return { 
        value: false 
    }
  },
  getters: {
    logined: state => {
        return state.value
    },
    token: () => {
        return localStorage.getItem(name)
    }
  },
  actions: {
    set(token) {
        localStorage.setItem(name, token);
        this.value = true;
    },
    remove() {
        localStorage.removeItem(name);
        this.value = false;
    }
  }
});
  